<%@ page import="java.util.List" %>
<%@ page import="cn.bdqn.pojo.Student" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>学生信息</title>
    <style>
        table {
            border-collapse: collapse;
            width: 100%;
        }

        th, td {
            text-align: left;
            padding: 8px;
        }

        tr:nth-child(even){background-color: #f2f2f2}

        th {
            background-color: #4CAF50;
            color: white;
        }
    </style>
</head>
<body>
<table class="studentList">
    <tr>
        <th>编号</th>
        <th>姓名</th>
        <th>密码</th>
        <th>性别</th>
        <th>年龄</th>
        <th colspan='2'>操作</th>
    </tr>
    <%
        List<Student> studentList = (List<Student>) request.getAttribute("studentList");
        for(Student student : studentList){
    %>
        <tr>
            <td><%=student.getId()%></td>
            <td><%=student.getName()%></td>
            <td><%=student.getLoginPassword()%></td>
            <td><%=student.getGender()%></td>
            <td><%=student.getAge()%></td>
            <td>
                <a href='${pageContext.request.contextPath}/student/selectById?id=<%=student.getId()%>'>修改</a>
                <a onclick="return confirm('是否删除？')" href='${pageContext.request.contextPath}/student/delete?id=<%=student.getId()%>'>删除</a>
            </td>

        </tr>
    <%
        }
    %>
        <tr>
            <th colspan="7">
                <form action="${pageContext.request.contextPath}/addStudent.jsp" method="post">
                    <input type="submit" value="添加">
                </form>
            </th>
        </tr>
</table>
</body>
</html>